package com.example.meterialproject.activitys

import android.os.Bundle
import com.example.meterialproject.R
import com.example.meterialproject.base.BaseActivity
import com.example.meterialproject.databinding.ActivityBottomAppBarBinding
import com.example.meterialproject.exts.showSnack
import com.google.android.material.bottomappbar.BottomAppBar

/**
 *
 * @ClassName: BottomAppBarActivity
 * @Author: android 超级兵
 * @CreateDate: 1/26/22$ 2:41 PM$
 * TODO BottomAppBar
 */
class BottomAppBarActivity : BaseActivity<ActivityBottomAppBarBinding>() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding.bottomAppBar2.setNavigationOnClickListener {
            it.showSnack("点击了navigation")
        }

        binding.bottomAppBar2.setOnMenuItemClickListener {
            when (it.itemId) {
                R.id.toolbar_menu_1,
                R.id.toolbar_menu_2,
                R.id.toolbar_menu_3,
                -> {
                    binding.bottomAppBar2.showSnack("点击了:${it.title}")
                    // 拦截 true
                    true
                }
                else -> {
                    false
                }
            }
        }

        binding.floatingButton2.setOnClickListener{
            val bottomAppBar = binding.bottomAppBar2

            if (bottomAppBar.fabAlignmentMode == BottomAppBar.FAB_ALIGNMENT_MODE_END) {
                bottomAppBar.fabAlignmentMode = BottomAppBar.FAB_ALIGNMENT_MODE_CENTER
            } else {
                bottomAppBar.fabAlignmentMode = BottomAppBar.FAB_ALIGNMENT_MODE_END
            }
        }



    }
}